#pragma once
#include "RoomStateBase.h"
#include "AssignPFState.h"
#include "BanState.h"
#include "PauseState.h"
#include "PickState.h"
#include "RoundOverState.h"
#include "StartState.h"

#include <vector>
using namespace std;


enum class RoomState{
    AssignPF,// Assign professions for teammates
    Ban,// Ban a profession
    Pause,// Pause the game
    Pick,// Pick a profession for the team
    RoundOver,//A round is over and waiting for the next round to start
    Start//Start the BP progress.
};



class RoomStateManager {


private:
 static  RoomStateBase* stateList[];

private:

    int StateTime; // Time left for the current state
    int roomID; // ID of the room this state manager belongs to

    vector<RoomState> statequeue; // Queue of states to be executed
    vector<int>stateOpTeamIndex; // Index of the team that is currently operating in the room in the state queue

    int curStateIndex; // Index of the current state in the state queue


    int OpTeamID; // ID of the team that is currently operating in the room,-1 if both teams are operating


public:
    RoomStateManager() = default; // Default constructor

    RoomStateManager(int roomID,vector<RoomState> statequeue,vector<int> stateOpTeamIndex) : roomID(roomID), statequeue(statequeue), stateOpTeamIndex(stateOpTeamIndex) {
        curStateIndex = 0; // Initialize current state index
        StateTime = 0; // Initialize state time
        OpTeamID = -1; // Initialize team ID

    }  

    RoomState getCurrentState() const {
        return statequeue[curStateIndex];
    }

    vector<RoomState> getStateQueue() const {
        return statequeue; // Return the state queue
    }

    int getRoomID() const {
        return roomID; // Return the room ID
    }

    int getOpTeamID() const {
        return OpTeamID; // Return the ID of the team that is currently operating in the room
    }

    void setOpTeamID(int teamID) {
        OpTeamID = teamID; // Set the ID of the team that is currently operating in the room
    }

    void setStateTime(int time) {
        StateTime = time; // Set the time left for the current state
    }

    int getStateTime() const {
        return StateTime; // Return the time left for the current state
    }

    void setStateIndex(int index) {
        curStateIndex = index; // Set the index of the current state in the state queue
    }

    int getStateIndex() const {
        return curStateIndex; // Return the index of the current state in the state queue
    }

    void Start(); // Start the state machine

    void NextState(); // Move to the next state in the state queue


    void DelRoom(); // Delete the room this state manager belongs to
};